<?php
/**

 * @property CI_Loader $load

 * @property CI_Form_validation $form_validation

 * @property CI_Input $input

 * @property CI_Email $email

 * @property CI_DB_active_record $db

 * @property CI_DB_forge $dbforge

 */
class Users extends CI_Model{
    
    //constructor
    function Users(){
        parent::__construct();
        $this->load->database();
    }
    
    
    /*
     * Check username and password exists in the database - Users table
     */
    function login($username,$password){
        $result=$this->db->query('select * from users where username="'.$username.'" and password="'.md5($password.'secret').'"');
        
        if($result->num_rows()==0){
            return false;
        }
        
        $query_result=$result->result();
        $userid=$query_result[0]->id;
        return $userid;
    }
    
    /*
     * Register user - update database with user details
     */
    function register($userdata){
        $this->db->insert('users',$userdata);
    }
}

?>
